import request from '@/utils/request'
const UpmsRoleServices = {
  actions: {
    /**
     * 角色分页
     */
    rolePage({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('role/page', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 角色列表
     */
    roleList({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.get('role/list', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 角色新增
     */
    roleSave({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('role/save', params).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 角色修改
     */
    roleUpdate({ commit }, params) {
      return new Promise((resolve, reject) => {
        request.post('role/update/' + params.id, {
          code: params.code,
          name: params.name,
          description: params.description
        }).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    },
    /**
     * 角色删除
     */
    roleRemove({ commit }, ids) {
      return new Promise((resolve, reject) => {
        request.post('role/remove', ids).then((res) => {
          resolve(res)
        }).catch((err) => {
          reject(err)
        })
      })
    }
  }
}
export default UpmsRoleServices
